

*Please read the Readme file before using this dofile 
*Data and code provided here are only for replication purposes. Please constact the author and the respective data owners if you wish to use the data for further analysis. 


*Please extend the file path for the data folder below 
global datadir ".../Replication data"
cd "$datadir"
use export_collapse_replication.dta, clear
xtset cs year





/*--------------------------------------------------------------
---Macros and programs
--------------------------------------------------------------*/
{
*This global is needed for most of the results. It ensures that fisheries after the year of collapse (after_col), fisheries that are shared with Japan (shared), Japanese fisheries, Japan's neighbours (neighjapan) are excluded. 
global cond "if after_col!=1 & shared!=1 & country!="Japan" & neighjapan==0 "

*For the results with the different definitions of collapse
global conddifferentcollapse "& shared!=1 & country!="Japan" & neighjapan==0 "

*For dynamic panel data analysis
global condyn "if year>=1976 & year<=2007 & highmig!=1 & highsea!=1"

global control "prevcol oceany*"
global baselinecluster " absorb(countrycode speciescode) cluster(speciescode) ffirst partial(oceany*)"

*The globals below facilitate the production of tables 
global tablefootorg "{l}{\footnotesize Standard errors in parentheses"
global tablefooter "{p{\textwidth}}{\footnotesize Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference." 
global tablefooterdep "{p{\textwidth}}{\footnotesize Dependent variable: Collapsed. Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference." 


*This program ist used post estimation. It saves relevant scalars, which are then shown in the results tables. 
capture program drop poste
program poste
	estadd local yearfe "Yes", replace
	estadd local sfe "Yes", replace
	estadd local cfe "Yes", replace
	estadd local iv1 "L.Col. Japan", replace
	estadd local iv2 "-", replace 
	estadd local controls "Yes", replace 
	matrix F=e(first)
	matrix B=F["SWF", 1]
	scalar swf=B[1,1]
	estadd scalar swf
	estadd scalar ar = e(arfp)
	estadd scalar clusterno = e(N_clust)
end

}


/*--------------------------------------------------------------
----Baseline regression
--------------------------------------------------------------*/
ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond, $baselinecluster 
estimate store exporttwo
poste
gen sample=1 if e(sample)==1


*The dataset below is used to generate the maps in Figures 7 and 8. 
preserve
gen insample=1 if sample==1 
xfill insample if year>=1976, i(cs)
keep if insample==1
save insample.dta, replace 
restore 


/*--------------------------------------------------------------
-----Summary statistics - Table 1
--------------------------------------------------------------*/
****within and overall variation 

{
gen lexportquantity=L.Exportquantity/1000
*Lag of export quantity measured in 1000 MT
gen lcoljapan=L.coljapan
gen lman=L.man
gen laglnprice=L.lnprice
gen laglnexportprice=L.lnexportprice

label variable collapsed "Collapsed"
label variable lexportquantity "Export quantity (lag)"
label variable l1exp "Export quantity (lag, ln)"
label variable laglnprice "Ex-vessel price (lag, ln)"
label variable laglnexportprice "Export price (lag, ln)"
label variable lman "Catch share (lag)"
label variable lcoljapan "Collapsed Japan (lag)"

*mean
foreach j in collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan{
xtsum `j' if sample==1
scalar sd`j'=r(mean)
matrix `j'D=(sd`j')
matrix list `j'D
}
matrix D= (collapsedD, lexportquantityD, l1expD, laglnpriceD,  laglnexportpriceD, lmanD, lcoljapanD)
matrix colnames D = collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan
matrix list D
reg collapsed lman if sample==1
estimates store mean
estadd matrix D

*overall variation
foreach j in collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan{
xtsum `j' if sample==1
scalar sd`j'=r(sd)
*scalar list sd`j'
matrix `j'D=(sd`j')
matrix list `j'D
}
matrix D= (collapsedD, lexportquantityD, l1expD, laglnpriceD,  laglnexportpriceD, lmanD, lcoljapanD)
matrix colnames D = collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan
matrix list D
reg collapsed lman if sample==1
estimates store overall
estadd matrix D

*within variation
foreach j in collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan{
xtsum `j' if sample==1
scalar sd`j'=r(sd_w)
*scalar list sd`j'
matrix `j'D=(sd`j')
matrix list `j'D
}
matrix D= (collapsedD, lexportquantityD, l1expD, laglnpriceD,  laglnexportpriceD, lmanD, lcoljapanD)
matrix colnames D = collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan
matrix list D
reg collapsed lman if sample==1
estimates store within
estadd matrix D

*between variation
foreach j in collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan {
xtsum `j' if sample==1
scalar sd`j'=r(sd_b)
*scalar list sd`j'
matrix `j'D=(sd`j')
matrix list `j'D
}
matrix D= (collapsedD, lexportquantityD, l1expD, laglnpriceD,  laglnexportpriceD, lmanD, lcoljapanD)
matrix colnames D = collapsed lexportquantity l1exp laglnprice laglnexportprice lman lcoljapan
matrix list D
reg collapsed lman if sample==1
estimates store between
estadd matrix D

esttab mean overall between within using Table1_summary_statistics.tex, replace main(D) label not nostar b(%15.3f) ///
mtitles ("Mean" "Overall Sd."  "Between Sd." "Within Sd.") ///
substitute("D coefficients" "Between Sd: Standard deviation between country-species combinations") ///
addnote("Within Sd: Standard deviation within country-species combinations")

}

/*--------------------------------------------------------------
-----Graph with the percentage of collapse fisheries - Figure 6
--------------------------------------------------------------*/

gen insample=1 if sample==1 
xfill insample if year>=1976, i(cs)

egen per_col=mean(collapsed) if insample==1, by(year)
egen year_col=mean(collapsed) if sample==1, by(year)
egen jappercol=mean(collapsed) if country=="Japan", by(year)
egen totexp=total(Exportquantity) if sample==1, by(year)
replace totexp=totexp/1000 
*Measured in 1000 MT 
label variable totexp "Total export quantity"
egen yeartag=tag(year)

foreach i in per_col year_col jappercol totexp{
xtset, clear
xfill `i', i(year)
}

*Growth in fishery exports and data reported in the summary stats 
su totexp if insample==1 & year==1976
scalar mean1976 = r(mean)
su totexp if insample==1 & year==1977
scalar mean1977 = r(mean)
su totexp if insample==1 & year==2006
scalar mean2006 = r(mean)
*growth
display (mean2006/mean1977)-1

*Summary statistics on the collapse in exporting countries 
su per_col if insample==1 & year==1976
su per_col if insample==1 & year==1991
su per_col if insample==1 & year==2006


*Summary statistics on the collapse of Japanese fisheries 
su jappercol if year==1976 & yeartag==1
su jappercol if year==2006 & yeartag==1



twoway area totexp year if yeartag==1 & year>=1976 & year<=2006, sort yaxis (2) fcolor(gs13) lcolor(gs13) ///
|| connected per_col year if yeartag==1 & year>=1976 & year<=2006, sort lpattern(longdash) yaxis(1)  ///
|| line year_col year if yeartag==1 & year>=1976 & year<=2006, sort yaxis(1) ///
|| line jappercol year if yeartag==1 & year>=1976 & year<=2006, sort lpattern(dash_dot) lcolor(navy) ///
 ytitle(Proportion of collapsed fisheries, axis(1)) ytitle(Export quantity in 1000 tonnes, axis(2)) xtitle(Year) xscale(range(1975 2006) extend) xlabel(1975(5)2010) xmtick(1975(5)2005) ///
legend(label(1 "Total exports")  label(2 "Proportion collapsed") label(3 "Collapsing fisheries") label(4 "Proportion collapsed Japan"))

graph export Figure6.png, replace

*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*--Correlation between collapse in Japan and prices, catch and exports - Table 2 
*------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

foreach i in lnprice lnexportprice lncatch lnExportquantity {
areg `i' coljapan oceany* i.countrycode if sample==1, absorb(speciescode) cluster(speciescode)
estimates store `i'col
estadd local yearfe "Yes", replace
estadd local cfe "Yes", replace
estadd local sfe "Yes", replace
estadd local controls "No", replace  
estadd local regionyearfe "Yes", replace  
estadd scalar clusterno = e(N_clust)
}

esttab lnpricecol lnexportpricecol lncatchcol lnExportquantitycol  using Table2_pricecorrelation.tex, replace /// 
se noconstant label s(controls yearfe clusterno N, label(Controls "FEs: $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$" "No. of clusters" "Observations" )) ///
b(%15.3f) ///
mtitles ("Price" "Export price" "Catch" "Exports" "Collapse") ///
keep(coljapan) ///
substitute ( ".000 " "" "<" "$<$" ///
"$tablefootorg" "{p\textwidth}{\footnotesize This table shows the conditional correlation between a collapse in Japan's Exclusive Economic Zone and the ex-vessel price (Column 1), the export price (Column 2), catch (Column 3) and exports (Column 4). All dependent variables are logged. Standard errors (clustered at the species level) in parentheses.") ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-----Baseline regression results - Table 3 
--------------------------------------------------------------*/
xtset cs year 

*Benchmark OLS
areg collapsed L.lnExportquantity $control i.countrycode if sample==1, absorb(speciescode) cluster(speciescode)
estimate store benchmarkols
estadd local controls "Yes"
estadd local yearfe "Yes", replace
estadd local cfe "Yes", replace
estadd local sfe "Yes", replace
estadd local iv1 "-", replace
estadd local iv2 "-", replace
estadd scalar clusterno = e(N_clust)

*Baseline regressions
ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond, $baselinecluster 
estimate store exporttwo
poste

*--------------------------------------------------------------
*--Interpretation of baseline regression results 

*-- Export growth in the median fishery is 
xtset cs year
foreach i of numlist 15 {
gen exp`i'growth=Exportquantity/L`i'.Exportquantity
su exp`i'growth if sample==1 & year==2006, detail
}

*--Sample for which data on export growth in this time period is available 
gen expgrowthavailable=1 if !missing(exp15growth) & sample==1 & year==2006
xfill expgrowthavailable, i(cs)


*-Generate rate of collapse from 1992 to 2006 
gen colafter1991=1 if collapsed==1 & sample==1 & year>1991 & year<=2006
xfill colafter1991, i(cs)
replace colafter1991=0 if missing(colafter1991)

*--Limit the sample to those that have data on export growth for 1992 to 2006 and are not collapsed in 1991.  
su colafter1991 if sample==1 & year==1991 & collapsed==0 & expgrowthavailable==1


*--------------------------------------------------------------
*--Table 3 

esttab benchmarkols exporttwo using Table3_baselineresults.tex, replace /// 
se noconstant label s( controls yearfe iv1 swf ar clusterno N,  label("Controls" "Fixed effects: $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$" "IV" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) sfmt(0) ///
b(%15.3f) ///
mtitles (Collapse Collapse) ///
order (L.lnExportquantity ) ///
keep(L.lnExportquantity) ///
substitute ( ".000" "" "&\multicolumn{1}{c}{Collapse}&" "\hline &\multicolumn{1}{l}{OLS}&\multicolumn{1}{l}{IV}\\ \hline Dependent variable: &\multicolumn{1}{c}{Collapse}&" "L.lnExportquantity" "Export quantity (lag, ln)" "{c}" "{l}" "$tablefootorg" "$tablefooter" "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 

*Reduced form 
areg collapsed L.coljapan $control i.countrycode if sample==1, absorb(speciescode) cluster(speciescode)


/*--------------------------------------------------------------
-----Managed and unmanaged fisheries - Table 4 
--------------------------------------------------------------*/

*--------------------------------------------------------------
*---Only fisheries that are not managed via a catch share program at the moment

ivreghdfe collapsed prevcol oceany* (L.lnExportquantity=L.coljapan) $cond & man==0, $baselinecluster
estimates store unmanagedonly
poste

*--------------------------------------------------------------
*---Only fisheries that are never managed via a catch share program throughout the sample period

ivreghdfe collapsed prevcol oceany* (L.lnExportquantity=L.coljapan) $cond & manlater==0, $baselinecluster 
estimates store nevermanaged
poste

*--------------------------------------------------------------
*---Only catch share fisheries

ivreghdfe collapsed prevcol oceany* (L.lnExportquantity=L.coljapan) $cond & man==1, $baselinecluster
estimates store managedonly
poste

*--------------------------------------------------------------
*-----All fisheries including an interaction term

gen expman=L.lnExportquantity*L.man
label variable expman "L. ln(Exports) $\times$ L.Catch share"
gen coljman=L.coljapan*L.man

ivreghdfe collapsed $control (L.lnExportquantity expman=L.coljapan coljman) L.man $cond , $baselinecluster 
estimates store interactman  
poste 
estadd local iv2 "L.Col. Japan $\times$ L. Managed", replace


esttab unmanagedonly nevermanaged managedonly interactman using Table4_managed.tex, replace /// 
se noconstant label s(sfe cfe swf ar clusterno N, label( "Controls" "FEs $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
nomtitles ///
order (L.lnExportquantity expman L.man) ///
keep(L.lnExportquantity expman L.man) ///
substitute ( ".000" "" "&\multicolumn{1}{c}{(4)}" "&\multicolumn{1}{c}{(4)}\\ Sample:&\multicolumn{1}{c}{Presently no}&\multicolumn{1}{c}{Never under}&\multicolumn{1}{c}{Catch}&\multicolumn{1}{c}{All}\\ &\multicolumn{1}{c}{catch share}&\multicolumn{1}{c}{catch share}&\multicolumn{1}{c}{share}&\multicolumn{1}{c}{ }\\" "L.lnExportquantity" "Export quantity (lag, ln)" "&\multicolumn{1}{c}{Catch share}" "Sample: &\multicolumn{1}{c}{Catch share}" "$tablefootorg" "$tablefooterdep" "<" "$<$") ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------------------------------------------------------------------
-- Effect of price on catch, exports and the probability of collapse - Table 5 
--------------------------------------------------------------------------------------------------------------------------*/


foreach k in Exportquantity catch{
ivreghdfe ln`k' $control (lnprice=L.coljapan) $cond & sample==1, $baselinecluster 
estimates store `k'price
poste
}

ivreghdfe collapsed $control (L.lnprice=L.coljapan) $cond & sample==1, $baselinecluster 
estimates store price2nd
poste


label variable lnprice "Ln(Price)"

esttab catchprice Exportquantityprice price2nd using Table5_price_iv.tex, replace ///
se noconstant label s(controls yearfe swf ar clusterno N, label("Controls" "Fixed effects: $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$" "1st stage F-Stat"  "Anderson-R. p-value" "No. of clusters" "Observations" )) ///
b(%15.3f) ///
mtitles ("Ln(Catch)" "Ln(Exports)" "Collapse") ///
keep(lnprice L.lnprice) ///
order(lnprice L.lnprice) ///
substitute ( ".000 " "" "$tablefootorg" "$tablefooter" "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-----Lags - Table 6
--------------------------------------------------------------*/

*--------------------------------------------------------------
*Lags 

foreach num of numlist 2/4 {
ivreghdfe collapsed prevcol oceany* (l`num'exp=l`num'colj)  $cond, $baselinecluster
estimates store l`num'
poste
estadd local iv1 "L`num'.Col. Jap.", replace
}

*--------------------------------------------------------------
*Maximum historical exports 
 
ivreghdfe collapsed $control (lnprevexp=L.coljapan) $cond, $baselinecluster 
estimates store lnprevexp
poste
label variable lnprevexp "Ln(Max. Exp. up to t)"

*--------------------------------------------------------------
*Years since the maximum 

ivreghdfe collapsed $control (years_since_max=L.coljapan) $cond & year<=2006 & year>1976, $baselinecluster 
estimates store years_since_max_2nd
poste
gen sample_years1=1 if e(sample)==1
replace sample_years1=0 if missing(sample_years1)


esttab l2 l3 l4 lnprevexp years_since_max_2nd using Table6_dynamics.tex, replace /// 
se noconstant label s( iv1 swf ar clusterno N, label("IV" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
mtitles (Collapse Collapse Collapse Collapse Collapse) ///
order ( l2exp l3exp l4exp lnprevexp years_since_max) ///
keep( l2exp l3exp l4exp lnprevexp years_since_max) ///
substitute ( ".000" "" "$tablefootorg" "{p{\textwidth}}{\footnotesize Ln(Max. Exp. up to t) represents the natural logarithm of the maximum historical export quantity recorded in fishery $ik$ up to time t. Years since max. exp measures the years since the last export peak. Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01)


/*--------------------------------------------------------------
-----Dynamics - Table 7
--------------------------------------------------------------*/
preserve 
drop if year<1966 

*----------------------------------------------------------------------
gen lnbiomass=ln(biomass)
*histogram lnbiomass

*----------------------------------------------------------------------
*Biomass as a function of exports 
xtset cs year

xi: xtabond2 lnbiomass L.lnbiomass L(1/1).lnExportquantity  L.man _Iyear_1977-_Iyear_2006 $condyn, gmmstyle(L.lnbiomass, laglimits(. 6) collapse) gmmstyle(L.lnExportquantity, laglimits(. 3) collapse) gmmstyle(L.man, laglimits(. 3) collapse) ivstyle(i.year) twostep robust noleveleq
estimates store biomass_exports 
estadd scalar instno=e(j) 
estadd scalar ar1pval=e(ar1p)            
estadd scalar ar2pval = e(ar2p)
estadd scalar hansenpval=e(hansenp)
nlcom _b[L.lnExportquantity]/(1-_b[L.lnbiomass]), post
matrix coef=e(b)
matrix list coef
scalar lr=coef[1,1]
estadd scalar lr: biomass_exports 

gen sampledyn=1 if e(sample)==1
su year if sampledyn==1

label variable lnbiomass "Ln(Biomass)"

xi: xtabond2 lnbiomass L.lnbiomass  L(1/3).lnExportquantity L.man _Iyear_1979-_Iyear_2006 $condyn, gmmstyle(L.lnbiomass, laglimits(. 6) collapse) gmmstyle(L.lnExportquantity, laglimits(. 3) collapse) gmmstyle(L.man, laglimits(. 3) collapse) ivstyle(i.year) twostep robust noleveleq
estimates store biomass_exports_3lags 
estadd local ll "3"
estadd scalar instno=e(j) 
estadd scalar ar1pval=e(ar1p)            
estadd scalar ar2pval = e(ar2p)
estadd scalar hansenpval=e(hansenp)

*----------------------------------------------------------------------
*Biomass as a function of the price 

xtset cs year
xi: xtabond2 lnbiomass L.lnbiomass L.lnprice L.man _Iyear_1977-_Iyear_2006 $condyn & sampledyn==1, gmmstyle(L.lnbiomass, laglimits(. 6) collapse) gmmstyle(L.lnprice, laglimits(. 5) collapse) gmmstyle(L.man, laglimits(. 4) collapse) ivstyle(i.year) twostep robust nolevele
estimates store biomasslnpricesample
estadd scalar instno=e(j) 
estadd scalar ar1pval=e(ar1p)            
estadd scalar ar2pval = e(ar2p)
estadd scalar hansenpval=e(hansenp)
nlcom _b[L.lnprice]/(1-_b[L.lnbiomass]), post
matrix coef=e(b)
matrix list coef
scalar lr=coef[1,1]
estadd scalar lr: biomasslnpricesample

xtset cs year
xi: xtabond2 lnbiomass L.lnbiomass L(1/3).lnprice  L.man _Iyear_1977-_Iyear_2006 $condyn & sampledyn==1, gmmstyle(L.lnbiomass, laglimits(. 6) collapse) gmmstyle(L.lnprice, laglimits(. 5) collapse) gmmstyle(L.man, laglimits(. 4) collapse) ivstyle(i.year) twostep robust noleveleq
estimates store biomasslnpricesample_3lags
estadd scalar instno=e(j) 
estadd scalar ar1pval=e(ar1p)            
estadd scalar ar2pval = e(ar2p)
estadd scalar hansenpval=e(hansenp)

*----------------------------------------------------------------------------------------
*Table for paper

esttab   biomass_exports biomass_exports_3lags biomasslnpricesample biomasslnpricesample_3lags using Table7_dynamics_biomass.tex, replace /// 
se noconstant label s(lr instno ar1pval ar2pval hansenpval N, label( "Long-run effect" "Instrument \#" "AR(1) p-value" "AR(2) p-value" "Hansen test p-value" "Observations")) ///
b(%15.3f) ///
mtitle ("Ln(Biomass)" "Ln(Biomass)" "Ln(Biomass)" "Ln(Biomass)") ///
order (L.lnbiomass   L.lnExportquantity L2.lnExportquantity L3.lnExportquantity L.lnprice L2.lnprice L3.lnprice L.man ) ///
keep(L.lnbiomass  L.lnExportquantity L2.lnExportquantity L3.lnExportquantity L.lnprice L2.lnprice L3.lnprice L.man ) ///
substitute (".000" " "     " 0 " " 0.000 " "L.lnExportquantity" "Export quantity (lag, ln)" "{l}{\footnotesize Standard errors in parentheses" "{p{\textwidth}}{\footnotesize Estimation is based on an Arellano-Bond estimator. Standard errors (clustered at the country-species level) in parentheses. Standard errors for the long-term effect are calculated using the delta method. AR(1) p-value and AR(2) p-value show the p-values for the Arellano-Bond test for first- and second-order serial autocorrelation in the first-differenced error term, respectively." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01)

*----------------------------------------------------------------------
*Adding the Japanese collapse as an instrument (mentioned in footnote)

*I exclude observations from Japan, fisheries that are shared with Japan and Japan's neighbours from the sample 
xtset cs year
xi: xtabond2 lnbiomass L.lnbiomass L.lnExportquantity  L.man _Iyear_1977-_Iyear_2006 $condyn & shared!=1 & country!="Japan" & neighjapan==0, gmmstyle(L.lnbiomass, laglimits(. 5) collapse) gmmstyle(L.lnExportquantity, laglimits(. 2) collapse) gmmstyle(L.man, laglimits(. 3) collapse) ivstyle(i.year L.coljapan) twostep robust noleveleq
estimates store incl_coljapan_iv
estadd scalar instno=e(j) 
estadd scalar ar1pval=e(ar1p)            
estadd scalar ar2pval = e(ar2p)
estadd scalar hansenpval=e(hansenp)
nlcom _b[L.lnExportquantity]/(1-_b[L.lnbiomass]), post
matrix coef=e(b)
matrix list coef
scalar lr=coef[1,1]
estadd scalar lr: incl_coljapan_iv

restore

/*--------------------------------------------------------------
-----No violation of instrument exogenoeity - Table 8
--------------------------------------------------------------*/
/*--------------------------------------------------------------
-----Landings of the Japanese fleet outside of their area */

xtreg landingsoutside coljapan i.year if country=="Japan" & shared!=1 & year>1976 & year<2006, fe robust
estimates store landingsoutside
estadd local yearfe "Yes", replace
estadd local sfe "Yes", replace
estadd local cfe "No", replace
estadd local regionyearfe "No", replace

/*--------------------------------------------------------------
-----Japanese landings in other EEZs */

ivreghdfe collapsed $control L.japland (L.lnExportquantity=L.coljapan)  $cond, $baselinecluster
estimates store japlandone
poste

/*--------------------------------------------------------------
-----Fisheries that collapse prior to the collapse in Japan */

gen priorjapcol=1 if initialcolyear<initialcoljapan & !missing(initialcolyear) & !missing(initialcoljapan)
count if priorjapcol==1 & sample==1

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & priorjapcol!=1, $baselinecluster
estimate store priorjapcol
poste

/*--------------------------------------------------------------
-----Exclude more areas of the sea  */

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & area67!=1 & area61!=1, $baselinecluster 
estimates store no67
poste

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & area71!=1 & area61!=1, $baselinecluster
estimates store no71
poste  


/*--------------------------------------------------------------
-----Longer time lags in the IV to ease concerns about El Nino */

foreach num of numlist 2 {
ivreghdfe collapsed $control (L.lnExportquantity=l`num'colj)  $cond, $baselinecluster
estimates store l`num'iv
poste
estadd local iv1 "L`num'.Col. Jap.", replace
}

label variable japland "Jap. catch"

esttab japlandone priorjapcol no67 no71 l2iv using Table8_instrument_exogeneity.tex, replace /// 
se noconstant label s(iv1 swf ar clusterno N, label( "IV" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations" )) ///
b(%15.3f) ///
nomtitles ///
posthead("\midrule &\multicolumn{1}{c}{Long distance}&\multicolumn{3}{c}{Sample excludes observations from}&\multicolumn{1}{c}{Lagged}\\ \cmidrule(lr){3-5} &\multicolumn{1}{c}{fleet catch}&\multicolumn{1}{c}{Early collapse}&\multicolumn{1}{c}{U.S., Canada}&\multicolumn{1}{c}{West Pacific}&\multicolumn{1}{c}{IV}\\ \hline") ///
order (L.lnExportquantity L.japland) ///
keep(L.lnExportquantity  L.japland) ///
substitute ( ".000 " "" "L.lnExportquantity" "Exports" "L.Col. Japan" "L.Col. Jap." /// 
"$tablefootorg" "{p\textwidth}{\footnotesize Dependent variable: Collapsed. Column 1 controls for catch by the Japanese long distance fleet in the FAO fishing area adjacent to the exporting country. Column 2 excludes all country-species-combinations from the sample in which the first reported collapse of fishery $i$ in the exporting country $k$ precedes the first reported collapse of fish species $i$ in Japan. Column 3: Sample excludes observations from U.S. and Canada. Column 4: Sample excludes observations from the Western Pacific. Column 5 uses the collapse in Japan in period $t-2$ as an instrument instead of the collapse in period $t-1$. Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (A.-R. p-value) provides weak instrument robust inference." ///
"multicolumn{1}{c}{(5)}\\" "multicolumn{1}{c}{(5)}\\ \midrule &\multicolumn{1}{c}{Long distance}&\multicolumn{3}{c}{Sample excludes observations from}&\multicolumn{1}{c}{Lagged}\\ \cmidrule(lr){3-5} &\multicolumn{1}{c}{fleet catch}&\multicolumn{1}{c}{Early collapse}&\multicolumn{1}{c}{U.S., Canada}&\multicolumn{1}{c}{West Pacific}&\multicolumn{1}{c}{IV}\\" ///
 "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-----Summary of collapsing fisheries - Table 11 
--------------------------------------------------------------*/

bysort isscaap_string: egen colsumcount=count(collapsed) if collapsed==1 & sample==1 
bysort isscaap_string: egen colsumcountjp=count(collapsed) if collapsed==1 & country=="Japan" & after_col!=1 & year>1976 & year<=2006 & isscaap_string!="Tunas, bonitos, billfishes " & isscaap_string!="Clams, cockles, arkshells "
label variable colsumcount "Collased fisheries"
label variable colsumcountjp "Collapsed fisheries Japan"

*Number of observations by speciesgroup in the sample 
bysort isscaap_string: egen countobs=count(collapsed) if sample==1 

*Table with number of observations 
estimates clear 
estpost tabstat countobs colsumcount colsumcountjp, by(isscaap_string) nototal
esttab using Table11_collapse_summary.tex, replace cells("countobs colsumcount colsumcountjp") noobs nomtitles nonumber varlabels(`e(labels)')  ///
addnote(This table shows the number of observations (Column 1) as well as the number of collapsing fisheries in exporting countries (Column 2) and Japan (Column 3) by species category.) ///
substitute ( ".000" """{l}{\footnotesize This table" "{p{\textwidth}}{\footnotesize This table" ".&" "0&" ".\\" "0\\" "colsumcountjp" "Japan" countobs " &  Collapse in & Collapse in \\ & Observations" colsumcount "exporting countries" )

xtset cs year 

/*----------------------------------------------------------------------------------------
--------Correlation - Collapse and Imports - Appendix table to put first stage into perspective  - Table 12 
----------------------------------------------------------------------------------------*/
xtset cs year 

areg Importquantity collapse i.year if country=="Japan" , absorb(speciescode) cluster(speciescode)
estimates store imp_collapse
estadd local yearfe "Yes", replace
estadd local sfe "Yes", replace
estadd scalar clusterno = e(N_clust)

areg lnImportquantity collapse i.year if country=="Japan" , absorb(speciescode) cluster(speciescode)
estimates store lnimp_collapse
estadd local yearfe "Yes", replace
estadd local sfe "Yes", replace
estadd scalar clusterno = e(N_clust)

esttab imp_collapse lnimp_collapse using Table12_imports_collapse.tex, replace /// 
se noconstant label s(yearfe sfe clusterno N, label("Year FE" "Species FE" "No. of clusters" "Observations" )) ///
b(%15.3f) ///
mtitles ("Japanese Imports" "Ln(Japanese Imports)") ///
keep(collapsed) ///
substitute ( ".000 " "" "<" "$<$" ///
"$tablefootorg" "{p\textwidth}{\footnotesize This table shows the conditional correlation between the collapse in Japan and Japanese imports. The dependent variable is the quantity of Japanese imports of species $i$ in year $t$. The regressor is the collapse of the species in Japan's EEZ. Year fixed effects capture time trends in imports that are constant across species. The regression also includes species fixed effects. The sample spans the years 1076-2006 and only contains Japanese fisheries. High seas and highly migratory fish species are excluded. Standard errors are clustered at the species level and given in parentheses." ) ///
starlevels(* 0.1 ** 0.05 *** 0.01)  



/*--------------------------------------------------------------
-----Robustness: Effect of exports on catch share fisheries - Table 13
--------------------------------------------------------------*/

*----Repetition of result in Column 4

ivreghdfe collapsed $control (L.lnExportquantity expman=L.coljapan coljman) L.man $cond , $baselinecluster 
estimates store interactman  
poste 
estadd local regionyearfe "\checkmark ", replace
estadd local cfe "\checkmark", replace
estadd local sfe "\checkmark", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe " ", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "L.Col. Japan $\times$ L. Managed", replace



*----Country-year fixed effects

egen countryyeardummy=group(countrycode year) if e(sample)==1, missing

ivreghdfe collapsed prevcol i.countryyear (L.lnExportquantity expman=L.coljapan coljman) L.man $cond , absorb(speciescode) cluster(speciescode) ffirst partial(i.countryyeardummy)
estimates store interactmancountryyearfe
poste 
estadd local regionyearfe " ", replace
estadd local cfe " ", replace
estadd local sfe "\checkmark", replace
estadd local countryyearfe "\checkmark", replace
estadd local countryspeciesfe " ", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "L.Col. Japan $\times$ L. Managed", replace



*----Country-species fixed effects 


ivreghdfe collapsed $control (L.lnExportquantity expman=L.coljapan coljman) L.man $cond, absorb(cs) cluster(speciescode) ffirst partial(oceany*)
estimates store interactmancountryspeciesfe
poste
estadd local regionyearfe "\checkmark", replace
estadd local cfe " ", replace
estadd local sfe " ", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe "\checkmark", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "L.Col. Japan $\times$ L. Managed", replace

esttab interactman interactmancountryyearfe interactmancountryspeciesfe using Table13_robustness_catch_share.tex, replace /// 
se noconstant label s(controls regionyearfe cfe sfe countryyearfe countryspeciesfe swf ar clusterno N, label( "Controls" "Region-Year FE" "Country FE" "Species FE"  "Country-Year FE" "Country-Species FE"  "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
nomtitles ///
order (L.lnExportquantity expman L.man) ///
keep(L.lnExportquantity expman L.man) ///
substitute ( ".000" "" "$tablefootorg" "The dependent variable is Collapsed$_{ikt}$. Collapse Japan$_{it-1}$  and  Collapse Japan$_{it-1} \times$ Catch share$_{ikt-1}$ are used as instruments for ln(Exports)$_{ikt-1}$ and ln(Exports)$_{ikt-1} \times$ Catch share$_{ikt-1}$.  The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference. Standard errors (clustered at the species level) in parentheses." "<" "$<$" "Yes" "\checkmark" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 



/*--------------------------------------------------------------
-----Catch share adoption is exogenous - Table 14
--------------------------------------------------------------*/

xtset cs year 
gen manind=1 if man[_n-1]==0 & man==1 & cs==cs[_n-1] 
gen notin=1 if man==1 & manind!=1

xtreg man L.collapsed i.year if notin!=1 & sample==1, fe robust 
estimates store catchshareadoptionsample 
estadd local yearfe "Yes", replace
estadd local csfe "Yes", replace
estadd local cfe "No", replace
estadd local sfe "No", replace

label variable collapsed "Collapsed"

esttab catchshareadoptionsample using Table14_catch_share_adoption.tex, replace /// 
se noconstant label s(yearfe N, label( "Country-species FE, Year FE" "Observations")) ///
b(%15.4f) ///
mtitles ("Catch share program$_{ikt}$ ") ///
order (L.collapsed) ///
keep(L.collapsed) ///
substitute ( ".0000" "" "<" "$<$" "L.Collapsed" "Collapsed_{ikt-1}" "$tablefootorg" "{p{\textwidth}}{\footnotesize This table shows the relationship between the collapse of a fishery $ik$ in year $t-1$ and the government's decision to introduce a catch share program for this fishery in year $t$. In the dataset used for this analysis, a fishery is observed up to the year in which it introduces a catch share program. Fisheries which do not introduce catch share programs are observed until the end of the sample period. Standard errors are clustered at the country-species level and given in parentheses.") ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-----Landings outside of Japan  - Table 15
--------------------------------------------------------------*/

xtreg landingsoutside coljapan i.year if country=="Japan" & shared!=1 & year>1976 & year<2006, fe robust
estimates store landingsoutside
estadd local yearfe "Yes", replace
estadd local sfe "Yes", replace
estadd local cfe "No", replace
estadd local regionyearfe "No", replace


esttab  landingsoutside using Table15_landingsoutside.tex, replace /// 
se noconstant label s( N, label( "Observations")) ///
b(%15.3f) ///
mtitles ("Long distance total catch") ///
order (coljapan) ///
keep(coljapan) ///
substitute ( ".000" "" "L.lnExportquantity" "Export quantity (lag, ln)" "{l}{\footnotesize Standard errors in parentheses" ///
"{p{\textwidth}}{\footnotesize The dependent variable $\text{Long distance total catch}_{it}$ measures the catch of species $i$ in year $t$ by Japanese vessels in all FAO fishing areas except the fishing area surrounding Japan. The variable is measured in tonnes and is constructed based on data from the FAO's Global Capture Production Database accessed through FishStat J. $\text{Long distance total catch}_{it}$ is regressed on the collapse of species $i$ in Japan in year $t$, on year fixed effects and species fixed effects. The sample does not include highly migratory and high seas fish stocks. Standard errors are clustered at the species level and given in parentheses." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-----Alternative instruments - Table 16
--------------------------------------------------------------*/

/*--------------------------------------------------------------
-----Japanese preferential import tariffs as a second instrument */

ivreghdfe collapsed $control (L.lnExportquantity = L.coljapan L.prefJapan) $cond, $baselinecluster
estimate store exportone
poste
estadd local iv2 "Tariff Japan", replace 


/*--------------------------------------------------------------
----- Interact the instruments with the distance from Japan (Not shown in paper but mentioned in footnote)*/

ivreghdfe collapsed $control (L.lnExportquantity=L.coldistjapan)  $cond, $baselinecluster
estimate store distance
poste
estadd local iv1 "Col. Japan*distance", replace 


/*--------------------------------------------------------------
----- Spillovers on demand side 
--------------------------------------------------------------*/

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan L.coljfamily ) $cond, $baselinecluster
estimate store spilloverfamily
poste
estadd local iv2 "L.Col. J. Family", replace

*First stage regressions 
areg L.lnExportquantity L.coljapan L.coljfamily  $control i.countrycode if sample==1, absorb(speciescode) cluster(speciescode)

esttab distance spilloverfamily using Table16_alternativeiv.tex, replace /// 
se noconstant label s(controls iv1 iv2 swf ar clusterno N, label( "FEs and controls" "IV 1" "IV 2" "1st stage F-Stat." "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
mtitles ("IV distance" "Substitution") ///
order ( L.lnExportquantity ) ///
keep( L.lnExportquantity ) ///
substitute ( ".000" "" "L.lnExportquantity" "Export quantity (lag, ln)" "L.coljapan" "L.Collapsed Japan" percolcs "Percentage collapsed" ///
"$tablefootorg" "{p\textwidth}{\footnotesize Dependent variable: Collapsed$_{ikt}$. Column 1 uses a different instrument: The collapse of the fishery in Japan is interacted with the exporter's distance from Japan. Column 2 uses a Japanese collapse in the same species family as a second instrument to assess substitution on the demand side. Standard errors (clustered at the species level) in parentheses." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 



/*--------------------------------------------------------------
-----Measurement error - Figure 11
--------------------------------------------------------------*/

foreach i of numlist 1/15{
	
*generating the alternative measure oif fisheries collapse 
gen collapsed`i'=1 if catch<=`i'/100*prevcatch & !missing(catch) & !missing(prevcatch)
replace collapsed`i'=0 if missing(collapsed`i') & !missing(catch)
su collapsed`i'

*Generating the indicator of when it switches
gen colind`i'=1 if collapsed`i'[_n-1]==0 & collapsed`i'==1 & cs==cs[_n-1] 

*generating the indicator of observations that have to be excluded since the fishery is collapsed
gen after_col`i'=1 if collapsed`i'==1 & colind`i'!=1

*indicator of collapse in Japan 
gen coljapan`i'=0 if year<=2006
replace coljapan`i'=1 if country=="Japan" & collapsed`i'==1
gsort alpha3 year -coljapan`i'
replace coljapan`i'=1 if coljapan`i'[_n-1]==1 & alpha3==alpha3[_n-1] & year==year[_n-1] & !missing(alpha3)

*Regression analysis
xtset cs year
ivreghdfe collapsed`i' $control (L.lnExportquantity=L.coljapan`i') if after_col`i'!=1 $conddifferentcollapse, $baselinecluster
estimates store collapsed`i'
poste
}

label variable lnExportquantity "Exports"
foreach num of numlist 2/15{
label variable collapsed`num' "`num'%"
}

coefplot (collapsed2 collapsed3 collapsed4 collapsed5 collapsed6 collapsed7 collapsed8 collapsed9 collapsed10 collapsed11 collapsed12 collapsed13 collapsed14 collapsed15), ///
keep(L.lnExportquantity) xline(0) aseq swapnames xtitle("Effect of an increase in lagged exports by 1%") ytitle("Collapse definition: Less than x %" "of maximum historical catch since 1950") ///
title ("Effect of exports on collapse") subtitle("using different definitions of collapse") ///
graphregion(ifcolor(white) fcolor(white) color(white) icolor(white)) bgcolor(white) 
graph export Figure11_collapsevariation15.png, replace


/*--------------------------------------------------------------
- Excluding observation where the collapse coincides with the adoption of a catch share programme
--------------------------------------------------------------*/

sort cs year

gen potentialerror=1 if manind==1 & collapsed==1 & sample==1
count if potentialerror==1
xfill potentialerror, i(cs)


ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & potentialerror!=1, $baselinecluster 
estimates store potentialerror1 
poste 
*This output is not shown in the paper but it discussed in Section C.3 Measurment error in fisheries collapse 


/*--------------------------------------------------------------
-----Table with different fixed effects - Table 17 
--------------------------------------------------------------*/

***FAO-area fixed effects 
xtset cs year
ivreghdfe collapsed prevcol faoarea* (L.lnExportquantity=L.coljapan) $cond, absorb(countrycode speciescode) cluster(speciescode) ffirst partial(faoarea*)
estimate store faoareayearfe
poste

estadd local yearonlyfe " ", replace
estadd local regionyearfe " ", replace
estadd local faoareayearfe "\checkmark", replace 
estadd local regiontimetrend "", replace
estadd local cfe "\checkmark", replace
estadd local sfe "\checkmark", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe " ", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "-", replace


*******
*Year FES
ivreghdfe collapsed prevcol i.year (L.lnExportquantity=L.coljapan) $cond, absorb(countrycode speciescode) cluster(speciescode) ffirst partial(i.year)
estimate store timefes
poste
estadd local yearonlyfe "\checkmark", replace
estadd local regionyearfe " ", replace
estadd local faoareayearfe " ", replace 
estadd local regiontimetrend " ", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe " ", replace
estadd local cfe "\checkmark", replace
estadd local sfe "\checkmark", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "-", replace

*******
*Ocean-region time trends 

*gen ocean time trends 
foreach i in 1 2{
gen year_ocean`i'=year*ocean`i'
}

ivreghdfe collapsed prevcol year_ocean1 year_ocean2 (L.lnExportquantity=L.coljapan) $cond, absorb(countrycode speciescode) cluster(speciescode) ffirst
estimate store regiontimetrend
poste
estadd local yearonlyfe " ", replace
estadd local regionyearfe " ", replace
estadd local faoareayearfe " ", replace 
estadd local regiontimetrend "\checkmark", replace
estadd local cfe " ", replace
estadd local sfe " ", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe " ", replace
estadd local cfe "\checkmark", replace
estadd local sfe "\checkmark", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "-", replace

*******
*Country-year fixed effects 
ivreghdfe collapsed prevcol i.year##i.countrycode (L.lnExportquantity=L.coljapan) $cond, absorb(speciescode) cluster(speciescode) ffirst partial(i.year##i.countrycode)
estimates store countryyearfe
poste
estadd local yearonlyfe " ", replace
estadd local regionyearfe " ", replace
estadd local faoareayearfe " ", replace 
estadd local regiontimetrend " ", replace
estadd local cfe " ", replace
estadd local sfe "\checkmark", replace
estadd local countryyearfe "\checkmark", replace
estadd local countryspeciesfe " ", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "-", replace

*******
*Country-species fixed effects 
ivreghdfe collapsed prevcol i.year (L.lnExportquantity=L.coljapan) $cond, absorb(cs) cluster(speciescode) ffirst partial(i.year)
estimates store countryspeciesfe
poste
estadd local yearonlyfe "\checkmark", replace
estadd local regionyearfe " ", replace
estadd local faoareayearfe " ", replace 
estadd local regiontimetrend "", replace
estadd local cfe " ", replace
estadd local sfe " ", replace
estadd local countryyearfe " ", replace
estadd local countryspeciesfe "\checkmark", replace
estadd local iv1 "Col. Japan", replace
estadd local iv2 "-", replace

esttab timefes regiontimetrend countryyearfe countryspeciesfe faoareayearfe using Table17_different_fes.tex, replace /// 
se noconstant label s(yearonlyfe regiontimetrend faoareayearfe sfe cfe countryyearfe countryspeciesfe controls swf ar clusterno N, label( "Year FE" "Region time trend" "FAO area-year FE" "Species FE" "Country FE" "Country-year FE" "Country-species FE" "Controls" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
nomtitles ///
order (L.lnExportquantity ) ///
keep(L.lnExportquantity ) ///
substitute (  ".000" " " "L.lnExportquantity" "Export quantity (lag, ln)" "$tablefootorg" "$tablefooter" "<" "$<$" "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 



/*--------------------------------------------------------------
-----Exports in levels - Figure 12 and Table 18
--------------------------------------------------------------*/

*---------------------------------------------------
*Histograms for export quantity of observations in the sample

gen Exportquantity_t=Exportquantity/1000
label variable Exportquantity_t "Export quantity in 1000 MT"

gen lagExportquantity_t=L.Exportquantity_t
label variable lagExportquantity_t  "L.Export quantity in 1000 MT"
gen laglnExportquantity=L.lnExportquantity
label variable laglnExportquantity "Export quantity in MT (Lagged, Ln)"

histogram lagExportquantity_t if sample==1
graph export Figure12_Exportquanitysample.jpg, replace
histogram laglnExportquantity if sample==1
graph export Figure12_lnExportquanitysample.jpg, replace 

*---------------------------------------------------
*Regression with exports in levels 

ivreghdfe collapsed $control (L.Exportquantity_t=L.coljapan) $cond & sample==1, $baselinecluster 
estimate store exportlevel_all
poste

*---------------------------------------------------
*Excluding outliers 

su L.Exportquantity_t  if sample==1, detail 

*The median ins 0.84. Cap at 100 time the median 
count if Exportquantity_t >85 & sample==1 & !missing(Exportquantity_t )
ivreghdfe collapsed $control (L.Exportquantity_t=L.coljapan) $cond & sample==1 & L.Exportquantity_t <=85, $baselinecluster 
estimate store exportlevel_outlier84
poste

*Cap at the 99th percentile 
count if Exportquantity_t >175 &sample==1 & !missing(Exportquantity_t )
ivreghdfe collapsed $control (L.Exportquantity_t=L.coljapan) $cond & sample==1 & L.Exportquantity_t <=175, $baselinecluster 
estimate store exportlevel_outlier175
poste

esttab exportlevel_all exportlevel_outlier84 exportlevel_outlier175 using Table18_exportlevel.tex, replace /// 
se noconstant label s(controls yearfe swf ar clusterno N, label("Controls" "Fixed effects: $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$" "1st stage F-Stat"  "Anderson-R. p-value" "No. of clusters" "Observations" )) ///
b(%15.3f) ///
mtitles ("Baseline" "Exports<85,000 MT" "Exports<175,000 MT") ///
keep(L.Exportquantity_t ) ///
substitute ( ".000 " "" "<" "$<$" ///
"$tablefootorg" "{p\textwidth}{\footnotesize Dependent variable: Collapsed. Regressor: Export quantity (in 1000 MT). Column 1 uses the same sample as the baseline regression. Columns 2 and 3 remove outliers with exports exceeding 85,000 MT (100 times the sample median) and 175,000 MT (the 99th percentile). Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference." "&\multicolumn{1}{c}{Baseline}" "Sample: &\multicolumn{1}{c}{Baseline}" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 

/*--------------------------------------------------------------
-----Alternative measures for openness - Table 19
--------------------------------------------------------------*/

*Ln net exports
ivreghdfe collapsed $control (L.lnnetexp=L.coljapan) $cond, $baselinecluster
estimates store lnnetexp
poste

*previous net exports 
ivreghdfe collapsed $control (lnprevnetexp=L.coljapan) $cond, $baselinecluster 
estimates store lnprevnetexp
poste

label variable lnprevexp "Ln(Max. Exp. up to t)"
label variable lnprevnetexp "Ln(Max. Net Exp.)"

/*--------------------------------------------------------------
-----Aquaculture - Part of Table 19 
--------------------------------------------------------------*/

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & aq==1, $baselinecluster 
estimates store aqua
poste

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) $cond & aq==0, $baselinecluster 
estimates store noaqua
poste


esttab  lnnetexp lnprevnetexp  aqua noaqua using Table19_netexports_aquaculture.tex, replace /// 
se noconstant label s( controls swf ar clusterno N, label( "Fixed effects and controls" "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
mtitles ("Collapsed" "Collapsed" "Collapsed" "Collapsed" ) ///
order ( L.lnnetexp  lnprevnetexp L.lnExportquantity ) ///
keep (L.lnnetexp  lnprevnetexp L.lnExportquantity ) ///
substitute ( ".000" "" "L.lnExportquantity" "Export quantity (lag, ln)" "&\multicolumn{1}{c}{Collapse}&" "Dependent variable: &\multicolumn{1}{c}{Collapse}&" ///
"\multicolumn{1}{c}{Collapsed}\\" "\multicolumn{1}{c}{Collapsed}\\ \hline Sample: &\multicolumn{1}{c}{All}&\multicolumn{1}{c}{All}&\multicolumn{1}{c}{Aquaculture}&\multicolumn{1}{c}{No aquaculture}\\" ///
"$tablefootorg" "{p{\textwidth}}{\footnotesize Column 1: The regressor \textit{Net exports} is defined as Exports-Imports. Column 2: The regressor it the natural logarithm of maximum historical net exports. Column 3: Sample includes all fisheries (country-species combinations) for which the FAO reports positive aquaculture production quantities. Column 4: Sample includes all fisheries for which the FAO does not report aquaculture production. Standard errors (clustered at the species level) in parentheses. The p-value of the \citet{Anderson1949} test (Anderson-R. p-value) provides weak instrument robust inference." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-- Interaction term between exports and the previous collapse of the fishery - Table 20 
--------------------------------------------------------------*/

*--------------------------------------------------------------
*----Exports * Previous collapse as second instrument  


gen expprevcol=L.lnExportquantity*prevcol
label variable prevcol "Prev. collapsed"
label variable expprevcol "L. ln(Exports) $\times$ Prev. collapsed"
gen coljapanprevcol=L.coljapan*prevcol

ivreghdfe collapsed $control (L.lnExportquantity expprevcol=L.coljapan coljapanprevcol) $cond , $baselinecluster 
estimates store expprevcol
poste 
estadd local iv2 "L.Col. Japan $\times$ Prev. collapsed", replace


esttab expprevcol using Table20_hetergeneitypreviouscollapse.tex, replace /// 
se noconstant label s(controls iv1 iv2 swf ar clusterno N, label( "FEs and controls" "IV 1" "IV 2" "1st stage F-Stat." "Anderson-R. p-value" "No. of clusters" "Observations")) ///
b(%15.3f) ///
mtitles ("Collapse") ///
order ( L.lnExportquantity expprevcol prevcol) ///
keep( L.lnExportquantity expprevcol prevcol ) ///
substitute ( ".000" "" "<" "$<$" ///
"$tablefootorg" "$tablefooter Prev. collapsed equals 1 if the fishery has collapsed in the past."  ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*--------------------------------------------------------------
-- Include observations from collapsed fisheries - Table 21
--------------------------------------------------------------*/

ivreghdfe collapsed $control (L.lnExportquantity=L.coljapan) if shared!=1 & country!="Japan" & neighjapan==0, $baselinecluster 
estimates store export_full
gen samplefull=1 if e(sample)==1
poste


areg L.lnExportquantity L.coljapan $control i.countrycode if samplefull==1, absorb(speciescode) cluster(speciescode)
estimates store first_full
estadd local controls "Yes"
estadd local yearfe "Yes", replace
estadd local cfe "Yes", replace
estadd local sfe "Yes", replace
estadd local iv1 "-", replace
estadd scalar clusterno = e(N_clust)


esttab first_full export_full using Table21_export_incl_collapsed.tex, replace /// 
se noconstant label s(  controls yearfe swf ar clusterno N,  label("Controls" "Fixed effects: $\gamma_{rt}$, $\gamma_{i}$, $\gamma_{k}$"  "1st stage F-Stat" "Anderson-R. p-value" "No. of clusters" "Observations")) sfmt(0) ///
b(%15.3f) ///
mtitles (Exports Collapse) ///
order (L.coljapan L.lnExportquantity) ///
keep(L.coljapan L.lnExportquantity) ///
substitute ( ".000" "" "&\multicolumn{1}{c}{Collapse}&" "\hline &\multicolumn{1}{l}{First stage}&\multicolumn{1}{l}{IV}\\ \hline Dependent variable: &\multicolumn{1}{c}{Collapse}&" "L.lnExportquantity" "Export quantity (lag, ln)" "{c}" "{l}" "$tablefootorg" "$tablefooter. The sample used here includes collapsed fisheries. Column 1 shows the first stage regression and Column 2 shows the IV results." "<" "$<$" ) ///
starlevels(* 0.1 ** 0.05 *** 0.01) 


/*------------------------------------------------------------------------------------------------------------------------------------------------------------
-------Figures ------
------------------------------------------------------------------------------------------------------------------------------------------------------------*/

*---------------------------------------------------------------------------------------------------
*Percentage of collapsed species - by species group - Figure 4
*---------------------------------------------------------------------------------------------------

use "$datadir/Japanese_data_isscaap_level.dta", clear

twoway  (line percolissdivision year if isscaapdivisioncode==2, sort lpattern(longdash)) ///
		(connected percolissdivision year if isscaapdivisioncode==3, sort ) ///
		(line percolissdivision year if isscaapdivisioncode==4, sort lpattern(dash)) ///
		(line percolissdivision year if isscaapdivisioncode==5 , sort lpattern(dash_dot)) ///
		if country=="Japan" & year>=1976 & year<=2006, ytitle(Percentage of collapsed fisheris in Japan) xtitle(Year) xscale(range(1975 2006) extend) xlabel(1975(5)2010) xmtick(1975(5)2005) yscale(range(0 0.8)) ///
		legend(order(1 "Diadromous fish" 2 "Marine fish" 3 "Crustaceans" 4 "Molluscs"))

graph export Figure4.png, replace

*---------------------------------------------------------------------------------------------------
*Role of Japan as a producer - at the issdivision level - Figure 10 - Appendix 
*---------------------------------------------------------------------------------------------------

twoway  (line share year if isscaapdivisioncode==2, sort lpattern(longdash)) ///
		(connected share year if isscaapdivisioncode==3, sort lpattern(dash_dot)) ///
		(line share year if isscaapdivisioncode==4, sort) ///
		(connected share year if isscaapdivisioncode==5 ,  sort) ///
		(line share year if isscaapdivisioncode==7, sort lpattern(shortdash)) ///
		if country=="Japan" & year>=1956 & year<=2006, ytitle(Japan's share of global catch) xtitle(Year) xscale(range(1975 2006) extend) xlabel(1975(5)2010) xmtick(1975(5)2005) yscale(range(0 0.8)) ///
		legend(order(1 "Diadromous fish" 2 "Marine fish" 3 "Crustaceans" 4 "Molluscs" 5 "Sea urchins/cucumbers" ))

graph export Figure10_japanproductionssharebyissdivision.png, replace 


*---------------------------------------------------------------------------------------------------
*Graph with food balance sheet data - Figure 5 
*---------------------------------------------------------------------------------------------------

use "$datadir/foodbalancesheet_japan.dta", clear

twoway (line export_quantity year, sort lpattern(longdash)) (line production year, sort) (line import_quantity year, sort lpattern(dash_dot)) (connected domesticsupply year, sort) if country=="Japan" & year>=1976 & year<=2006, ytitle(Quantity in 1000 tonnes) xtitle(Year) xscale(range(1975 2006) extend) xlabel(1975(5)2010) xmtick(1975(5)2005) ///
legend(label (1 "Export quantity") label(2 "Catch") label(3 "Import quantity") label (4 "Domestic supply")) title(Japanese catch and trade in fisheries products)

graph export Figure5_japannetexpfoodbalancesheet.png, replace

*---------------------------------------------------------------------------------------------------
*Maps -- Figures 6 and 7 
*---------------------------------------------------------------------------------------------------
/* note that this requires the datasets worldmap.dta and worldcoord.dta as well as a number of additional stata programs by Michael Stepner (https://michaelstepner.com/maptile/)
Those can be installed using the following commands
ssc install maptile
ssc install spmap
ssc install shp2dta 
ssc install mif2dta

Moreover, the maps require a shape file. The shape file used in this paper is from Thematic Mapping API and was downloaded using the following link. https://thematicmapping.org/downloads/world_borders.php

The shapefile needs to be transformed into a stata file using the follwing command, which will generate the datasets worldmap and worldcoord used below. 
 
shp2dta using TM_WORLD_BORDERS, database(worldmap) coordinates(worldcoord) genid(iso3) replace

*/

use insample.dta, clear
drop if year>2006 | year<1976

*-----------------------------------------------------------------------------------------------
*Generating the percentage of collapsed species per country amongst the species in the sample
 
bysort countryiso3 year: egen colnum=total(collapsed), missing
label variable colnum "Total number of collapsed species"
bysort countryiso3 year: egen specnum=count(collapsed)
label variable specnum "Total number of species in the sample"
gen percol=colnum/specnum
label variable percol "Percentage of collapsed species"

*-----------------------------------------------------------------------------------------------
*Generating the variable for exports 

replace Exportquantity=Exportquantity/1000
*Export quantity is now measured in 1000 MT 
foreach i in catch Exportquantity{
egen `i'totalyear=total(`i'), by(countryiso3 year) 
egen `i'totalav=mean(`i'totalyear), by(countryiso3) 
}

keep if year==2006
keep country year countryiso3 percol Export*
egen countryiso3yeartag=tag(countryiso3 year)
keep if countryiso3yeartag==1
rename countryiso3 ISO3
drop countryiso3yeartag

merge 1:1 ISO3 using "$datadir/worldmap.dta"
drop if ISO3=="ATA"
drop if _merge==1


*---------------------------------------------------------------------------------------------------
*Figure 7 - Map with the percentage of collapsed fisheries 
*---------------------------------------------------------------------------------------------------

spmap percol using "$datadir/worldcoord.dta", id(iso3) fcolor(BuRd)  clmethod(custom) clbreaks(0 0.1 0.2 0.3 1) ///
legen (label(2 "0-10 percent") label(3 "10-20 percent") label(4 "20-30 percent") label(5 "30-100 percent")) legtitle ("Percentage of collapsed fisheries, 2006") ///
legend(size(medium))
graph export Figure7_map_collapse.png, replace 


*---------------------------------------------------------------------------------------------------
*Figure 8 - Map with the country's total exports, averaged over the sample period
*---------------------------------------------------------------------------------------------------

su Exportquantitytotalav, detail
spmap Exportquantitytotalav using "$datadir/worldcoord.dta", id(iso3) fcolor(BuRd) clmethod(custom) clbreaks(0 0.5 1 10 100 1000) ///
legtitle ("Export quantity in 1000 tonnes" "(average over sample period)") ///
legend(size(medium))
graph export Figure8_map_exports.png, replace 


